package server;

import javax.naming.Context;
import javax.naming.InitialContext;

public class Apl {
	public static void main( String[] args ) {

		try {

			Context initialNamingContext = new InitialContext();

			// Create Core
			CoreImpl core = new CoreImpl();

			// Create categories
			core.addCategory( "Kitchen appliances" );
			core.addCategory( "Living room" );

			// Add product to product list
			String name = "Toaster";
			ProductImpl product1 = new ProductImpl( core.getCategory( "Kitchen appliances" ), name, 20.95 );
			core.addToProductList( product1 );

			// Add product to product list
			name = "Blender";
			ProductImpl product2 = new ProductImpl( core.getCategory( "Kitchen appliances" ), name, 39.95 );
			core.addToProductList( product2 );

			// Add products to product list
			name = "Sofa";
			ProductImpl product3 = new ProductImpl( core.getCategory( "Living room" ), name, 210.00 );
			core.addToProductList( product3 );
			name = "Stoel";
			ProductImpl product8 = new ProductImpl( core.getCategory( "Living room" ), name, 110.00 );
			core.addToProductList( product8 );
			name = "Lamp";
			ProductImpl product9 = new ProductImpl( core.getCategory( "Living room" ), name, 40.00 );
			core.addToProductList( product9 );

			name = "Messenblok";
			ProductImpl product4 = new ProductImpl( core.getCategory( "Kitchen appliances" ), name, 50.00 );
			core.addToProductList( product4 );

			// Add products to product list
			name = "Knife";
			ProductImpl product5 = new ProductImpl( core.getCategory( "Kitchen appliances" ), name, 3.50 );
			core.addToProductList( product5 );
			name = "Dobbel Toaster";
			ProductImpl product6 = new ProductImpl( core.getCategory( "Kitchen appliances" ), name, 155.45 );
			core.addToProductList( product6 );
			name = "Mandoline";
			ProductImpl product7 = new ProductImpl( core.getCategory( "Kitchen appliances" ), name, 30.90 );
			core.addToProductList( product7 );

			initialNamingContext.rebind( "core", core );


			System.out.println( "Server is gestart." );
		} catch( Exception e ) {
			System.out.println( "Error: " + e.getMessage() );
			e.printStackTrace();

		}
	}
}
